package io.github.luons.mediator.core.validator;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Null;
import java.lang.annotation.*;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * EnumMember validator annotation
 *
 * @author : luons
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Constraint(validatedBy = {EnumMemberValidator.class})
public @interface EnumMember {

    /**
     * message
     */
    String message() default "{Member invalid}";

    /**
     * groups
     */
    Class<?>[] groups() default {};

    /**
     * payload function
     */
    Class<? extends Payload>[] payload() default {};

    /**
     * Target enum class.
     */
    Class<?> value() default Class.class;

    /**
     * Target enum class's method name, used to get the member object.
     */
    String method() default "getCode";

    /**
     * Defines several {@link EnumMember} annotations on the same element.
     *
     * @see EnumMember
     */
    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        Null[] value();
    }

}
